-
-
Notifications
You must be signed in to change notification settings - Fork 391
Improve update logic & Fix update logic issue & Input for Query #3502
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves the update logic in the main view model by refactoring how running and current queries are tracked and by updating the QueryBuilder.Build method signature to accept separate input and trimmed text parameters.
- Refactored MainViewModel to replace _isQueryRunning with two distinct query state variables.
- Updated QueryBuilder.Build calls in view model, tests, and main window to pass both raw and trimmed query text.
- Added documentation for the new Query.Input property and corresponding changes in QueryBuilder.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
Flow.Launcher/ViewModel/MainViewModel.cs | Refactored query state tracking and updated QueryBuilder.Build invocations. |
Flow.Launcher/MainWindow.xaml.cs | Updated QueryBuilder.Build call for consistency in query text handling. |
Flow.Launcher.Test/QueryBuilderTest.cs | Adjusted tests to accommodate the updated QueryBuilder.Build signature. |
Flow.Launcher.Plugin/Query.cs | Added Input property documentation. |
Flow.Launcher.Core/Plugin/QueryBuilder.cs | Changed Build method signature to accept both raw input and trimmed text. |
Comments suppressed due to low confidence (1)
Flow.Launcher/ViewModel/MainViewModel.cs:372
- [nitpick] Ensure that passing the untrimmed QueryText as the first parameter while the second parameter is trimmed is the intended behavior, and document this design choice for clarity.
var query = QueryBuilder.Build(QueryText, QueryText.Trim(), PluginManager.NonGlobalPlugins);
This comment has been minimized.
This comment has been minimized.
Be a legend 🏆 by adding a before and after screenshot of the changes you made, especially if they are around UI/UX. |
This comment has been minimized.
This comment has been minimized.
Warning Rate limit exceeded@Jack251970 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 50 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis change updates the query construction and management logic across the codebase. The Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant MainWindow
participant MainViewModel
participant QueryBuilder
participant Query
User->>MainWindow: Types or edits query
MainWindow->>MainViewModel: Passes QueryText (raw input)
MainViewModel->>QueryBuilder: Build(raw input, processed text, plugins)
QueryBuilder->>Query: Constructs Query (with Input property)
Query-->>MainViewModel: Returns Query object
MainViewModel->>MainViewModel: Tracks _progressQuery and _updateQuery
MainViewModel->>MainWindow: Updates UI/results
Estimated code review effort3 (30–60 minutes) — The changes affect multiple core components with moderate complexity, including method signature updates, state management refactoring, and asynchronous task handling. Possibly related PRs
Suggested reviewers
✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
Flow.Launcher/ViewModel/MainViewModel.cs (2)
239-265
: Redundant guards – can be collapsed for clarityThe same three-part condition (
_currentQuery == null || e.Query.RawQuery != _currentQuery.RawQuery || …
) is evaluated twice, once before cloning the results and once after.
Keeping a single guard at the top of the handler avoids duplication and a tiny amount of wasted work.- if (_currentQuery == null || e.Query.RawQuery != _currentQuery.RawQuery || e.Token.IsCancellationRequested) - { - return; - } - - var token = e.Token == default ? _updateSource.Token : e.Token; - … - if (_currentQuery == null || e.Query.RawQuery != _currentQuery.RawQuery || token.IsCancellationRequested) - { - return; - } + var token = e.Token == default ? _updateSource.Token : e.Token; + if (_currentQuery == null || + e.Query.RawQuery != _currentQuery.RawQuery || + token.IsCancellationRequested) + { + return; + }
372-373
: Minor readability nit – avoid double-trim
QueryText
is already passed as the raw input. CallingQueryText.Trim()
for the second parameter means the string is trimmed twice insideBuild
. You can save an allocation by trimming once:-var query = QueryBuilder.Build(QueryText, QueryText.Trim(), PluginManager.NonGlobalPlugins); +var trimmed = QueryText.Trim(); +var query = QueryBuilder.Build(QueryText, trimmed, PluginManager.NonGlobalPlugins);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
Flow.Launcher.Core/Plugin/QueryBuilder.cs
(3 hunks)Flow.Launcher.Plugin/Query.cs
(1 hunks)Flow.Launcher.Test/QueryBuilderTest.cs
(3 hunks)Flow.Launcher/MainWindow.xaml.cs
(1 hunks)Flow.Launcher/ViewModel/MainViewModel.cs
(9 hunks)
🧰 Additional context used
🧠 Learnings (1)
Flow.Launcher/ViewModel/MainViewModel.cs (1)
Learnt from: Yusyuriv
PR: Flow-Launcher/Flow.Launcher#3118
File: Flow.Launcher/ViewModel/MainViewModel.cs:1404-1413
Timestamp: 2024-12-08T21:12:12.060Z
Learning: In the `MainViewModel` class, the `_lastQuery` field is initialized in the constructor and is never null.
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: gitStream.cm
- GitHub Check: gitStream.cm
- GitHub Check: build
🔇 Additional comments (11)
Flow.Launcher.Plugin/Query.cs (1)
10-14
: Good addition of theInput
property with clear documentationThe new
Input
property with appropriate XML documentation clearly explains its purpose and usage guidance. The warning about usingSearch
property instead is consistent with the documentation forRawQuery
.Flow.Launcher/MainWindow.xaml.cs (1)
411-411
: UpdatedQueryBuilder.Build
call with proper parametersThe call has been correctly updated to pass both the raw query text and the trimmed text as separate parameters, aligning with the updated method signature in
QueryBuilder.cs
.Flow.Launcher.Test/QueryBuilderTest.cs (3)
19-19
: Test adjusted to use updatedQueryBuilder.Build
signatureThe test call has been properly updated to include the raw input parameter, maintaining test integrity while accommodating the API change.
42-42
: Test adjusted to use updatedQueryBuilder.Build
signatureThe test call has been properly updated to include the raw input parameter, maintaining test integrity while accommodating the API change.
54-54
: Test adjusted to use updatedQueryBuilder.Build
signatureThe test call has been properly updated to include the raw input parameter, maintaining test integrity while accommodating the API change.
Flow.Launcher.Core/Plugin/QueryBuilder.cs (4)
9-9
: Method signature updated to include the raw input parameterThe
Build
method signature has been enhanced to accept the raw input as a separate parameter, which will be used to populate the newInput
property on theQuery
class.
14-15
: Minor formatting changeSmall formatting adjustment with no functional impact.
25-26
: Additional whitespace added for readabilitySmall formatting improvement to enhance code readability.
Also applies to: 32-33
42-42
: Correctly setting the newInput
propertyThe new
Input
property is properly populated with the raw input parameter, completing the implementation of this feature.Flow.Launcher/ViewModel/MainViewModel.cs (2)
1274-1281
: Potential visibility race on_runningQuery
_runningQuery
is written on the UI thread and later read from aTask.Delay
continuation running on a ThreadPool thread.
Although reference assignments are atomic, withoutvolatile
/Interlocked
there is no publish-happens-before relation; the ThreadPool may observe a stale value.If correctness depends on the most recent write, consider:
private volatile Query _runningQuery;or guarding access with a lock/
Interlocked.Exchange
.Would you verify if stale reads could surface in practice? If so, I can help prepare a patch.
1396-1397
: Verify parameter order matchesQueryBuilder.Build
signatureJust a sanity check:
Build(rawInput, processedText, nonGlobalPlugins)
is expected.
Confirm thatQueryText
(raw) andqueryBuilder.ToString().Trim()
(processed) are in the correct order to ensureQuery.Input
holds the unmodified user text.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (2)
Flow.Launcher/ViewModel/MainViewModel.cs (2)
35-36
: Improved state tracking with dedicated Query objectsThis is a good improvement over using a boolean flag. Tracking queries as objects allows for more precise state management and validation.
The existing suggestion to rename these variables to
_progressQuery
and_updateQuery
to more clearly indicate their purposes is still valid.
1254-1255
:⚠️ Potential issueCompile-time error:
TaskScheduler
is not awaitable
await TaskScheduler.Default;
will not compile becauseTaskScheduler
does not implementGetAwaiter()
.-// Switch to ThreadPool thread -await TaskScheduler.Default; +// Switch to ThreadPool thread +await Task.Yield(); // or `await Task.Run(() => {}, _updateSource.Token);`
🧹 Nitpick comments (1)
Flow.Launcher/ViewModel/MainViewModel.cs (1)
260-263
: Redundant validation checkThis is a duplicate of the check on line 240. While it's valid to verify conditions haven't changed, consider extracting this validation to a helper method to avoid duplication.
-if (_updateQuery == null || e.Query.RawQuery != _updateQuery.RawQuery || token.IsCancellationRequested) -{ - return; -} +if (IsQueryMismatchOrCancelled(_updateQuery, e.Query, token)) +{ + return; +} // Add this helper method to the class +private bool IsQueryMismatchOrCancelled(Query currentQuery, Query eventQuery, CancellationToken token) +{ + return currentQuery == null || eventQuery.RawQuery != currentQuery.RawQuery || token.IsCancellationRequested; +}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
Flow.Launcher/ViewModel/MainViewModel.cs
(9 hunks)
🧰 Additional context used
🧠 Learnings (1)
Flow.Launcher/ViewModel/MainViewModel.cs (1)
Learnt from: Yusyuriv
PR: Flow-Launcher/Flow.Launcher#3118
File: Flow.Launcher/ViewModel/MainViewModel.cs:1404-1413
Timestamp: 2024-12-08T21:12:12.060Z
Learning: In the `MainViewModel` class, the `_lastQuery` field is initialized in the constructor and is never null.
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: gitStream workflow automation
- GitHub Check: gitStream.cm
- GitHub Check: build
🔇 Additional comments (9)
Flow.Launcher/ViewModel/MainViewModel.cs (9)
240-240
: Fixed update logic comparisonThis fixes the core issue where the update logic incorrectly compared
e.Query.RawQuery
withQueryText
instead of comparing equivalent objects.
373-373
: Updated QueryBuilder.Build call with Input parameterCorrectly updated to pass both raw input and trimmed text to match the updated signature.
1221-1221
: Reset query state before processingGood practice to initialize the query state before starting a new query process.
1241-1246
: Early return optimization for changed queriesThis is a good optimization to prevent processing outdated queries when user input changes rapidly.
1251-1252
: Improved query state trackingSetting both the progress and update query objects provides better tracking of the query lifecycle.
1291-1302
: Progress bar visibility linked to query stateGood implementation of delayed progress bar visibility that also checks if the query is still active before showing it.
1325-1332
: Reset progress query after completionProperly manages the progress state and progress bar visibility after query execution completes.
1334-1338
: Added safety with try-finally blockThe finally block ensures the query state is cleaned up even if an exception occurs, preventing state leakage.
1414-1414
: Updated call to match new QueryBuilder.Build signatureCorrectly updated to provide both the original input and the processed query string.
Until we can actually figure out what's causing it. |
This comment has been minimized.
This comment has been minimized.
🥷 Code experts: theClueless Jack251970 has most 👩💻 activity in the files. See details
Activity based on git-commit:
Knowledge based on git-blame:
Activity based on git-commit:
Knowledge based on git-blame:
Activity based on git-commit:
Knowledge based on git-blame:
Activity based on git-commit:
Knowledge based on git-blame:
Activity based on git-commit:
Knowledge based on git-blame: To learn more about /:\ gitStream - Visit our Docs |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
So do you want to close this or mark craft? |
sorry, I cannot get it. all works have been done here and it should be ready for review
…---Original---
From: "Jeremy ***@***.***>
Date: Tue, Jun 17, 2025 17:39 PM
To: ***@***.***>;
Cc: "Jack ***@***.******@***.***>;
Subject: Re: [Flow-Launcher/Flow.Launcher] Improve update logic & Fix updatelogic issue & Input for Query (PR #3502)
jjw24 left a comment (Flow-Launcher/Flow.Launcher#3502)
So do you want to close this or mark craft?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Oh ok so these changes are still relevant |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I don't really understand this line. I think query text is equal to RawQuery. Are we talking about some key expansion? |
As you can I see, now I add |
make sense |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@check-spelling-bot Report🔴 Please reviewSee the 📂 files view, the 📜action log, or 📝 job summary for details.
See ❌ Event descriptions for more information. Forbidden patterns 🙅 (1)In order to address this, you could change the content to not match the forbidden patterns (comments before forbidden patterns may help explain why they're forbidden), add patterns for acceptable instances, or adjust the forbidden patterns themselves. These forbidden patterns matched content: s.b. workaround(s)
If the flagged items are 🤯 false positivesIf items relate to a ...
|
From #3314. Resolve #2605.
Improve update logic
Improve main view model update logic.
Fix update logic issue
We should not use
e.Query.RawQuery != QueryText
becauseQueryText
(Input) is different fromRawQuery
(Query).Add new property Input for Query
Input
is the property without trimming whitespace and it can help developer get the raw input.Clear results when there are no update tasks
In this function, we need to reset all things because there are no update tasks.
Test